package com.yh.serviceImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.yh.bean.Inorder;
import com.yh.dao.InorderDao;
import com.yh.dao.IntegralGoodsDao;
import com.yh.service.InorderService;


@Service
public class InorderServiceImpl implements InorderService {	
	@Autowired	
	private InorderDao InorderDao;
	@Autowired
	private IntegralGoodsDao IntegralGoodsDao;
	
	@Override
	public boolean addInorder(Inorder in) {		
		InorderDao.addInorder(in);			
		IntegralGoodsDao.updateIngStock(in.getIng_id());
		return true;
	}

	@Override
	public Map<?, ?> loadInoder(int currentPage) {						
			Page page=PageHelper.startPage(currentPage,5);				
			List<Inorder> orderList=InorderDao.loadInorder();			
			System.out.println("=================="+orderList);
				int pages=page.getPages();			
			Map<Object,Object> map=new HashMap<>();
			map.put("orderList", orderList);			
			
			map.put("pages", pages);			
			return map;
		}	

}
